#include<vector>
#include<iostream>
using namespace std;
namespace bit
{
	template<size_t N>
	class BitSet
	{
	public:
		BitSet()
		{
			bit.resize(N / 32 + 1);
		}
		void set(size_t i)
		{
			int x = i / 32;
			int y = i % 32;
			bit[x] |= (1 << y);
		}
		void reset(size_t i)
		{
			int x = i / 32;
			int y = i % 32;
			bit[x] &= (0 << y);
		}
		bool text(size_t i)
		{
			int x = i / 32;
			int y = i % 32;
			return bit[x] & (1 << y);
		}
	private:
		vector<int> bit;
	};



	template<size_t N>
	class twobit
	{
	public:
		void set(size_t i)
		{
			//00->01
			if (!bit1.text(i) && !bit2.text(i))
			{
				bit2.set(i);
			}
			else if (!bit1.text(i) && bit2.text(i))//01->10
			{
				bit1.set(i);
				bit2.reset(i);
			}
		}
		bool once_math(size_t i)
		{
			return (!bit1.text(i) && bit2.text(i));
		}
	private:
		BitSet<N> bit1;
		BitSet<N> bit2;
	};
}
